#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool dfs(string& s, int left, int right, bool flag)
    {
        if (left >= right)
            return true;
        if (s[left] == s[right])
            return dfs(s, left + 1, right - 1, flag);
        else if (flag)
            return dfs(s, left + 1, right, false) || dfs(s, left, right - 1, false);
        else
            return false;
    }
    bool validPalindrome(string s) {
        int left = 0, right = s.size() - 1;
        return dfs(s, 0, s.size() - 1, true);
    }
};